<?php

class Loginmodel extends CI_Model {

	private $conturi = 'conturi';
	
	function este_logat()
	{
		return ($this->session->userdata('logat') === TRUE);
	} 
	function logout()
	{
		$this->session->sess_destroy();
	}

	function autentifica($email, $parola)
	{
		$data = array(
				'email' => $email,
				'pass' => $parola,
				'activ' => 1
		);
		$this->db->where($data); 
		$query = $this->db->get($this->conturi);
		var_dump($query);
		if($query->num_rows() == 0 )
		{
			return 0;
		}
		else 
		{
			$row = $query->row(); 	
		
			$newdata = array(
				'nume'  => $row->nume,
				'prenume' => $row->prenume,
				'email'   => $email,
				'logat' => TRUE	   
			);

			$this->session->set_userdata($newdata);
			return 1;
		}
	}

}
?>